package com.xdl.backstage.base.service.logic;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.xdl.backstage.base.dao.CompanyDao;
import com.xdl.backstage.base.dao.UserManagerDao;
import com.xdl.backstage.base.domain.Company;
import com.xdl.backstage.base.domain.UserManager;
import com.xdl.backstage.base.entity.CompanyEntity;
import com.xdl.backstage.base.entity.UserManagerEntity;

public class UserServiceLogic {

	private static volatile UserServiceLogic instance = null;

	private UserManagerDao userManagerDao;
	
	private Map<String, UserManager> mapUser;
	
	public static UserServiceLogic getInstance(UserManagerDao userManagerDao) {
		if (instance == null) {
			synchronized (CompanyServiceLogic.class) {
				if (instance == null) {
					instance = new UserServiceLogic(userManagerDao);
				}
			}
		}
		return instance;
	}
	
	private UserServiceLogic(UserManagerDao userManagerDao) {
		this.userManagerDao = userManagerDao;
		List<UserManager> listAll =  userManagerDao.queryDataByParams();
		mapUser  = new HashMap<>();
		if (listAll != null) {
			for (UserManager data : listAll) {
				mapUser.put(data.getId(), data);
			}
		}
	}
	
	public UserManager getData(String companId) {
		if (this.mapUser.containsKey(companId)) {
			return this.mapUser.get(companId);
		}
		return null;
	}
	
	
	
}

